home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 101-125 / disk_107 / svtools / setstack / setstack.c < prev   
C/C++ Source or Header  |  1992-05-06  |  3KB  |  102 lines

  1. /************************************************************
  2.   setstack.c  By: Stephen Vermeulen
  3.  
  4.   Copyright (C) 1987 By Stephen Vermeulen
  5.  
  6.   Use this tool to set the stack of an icon.
  7.  
  8.   It has the following syntax:
  9.  
  10.       setstack file amount
  11.  
  12.   The above sets the stack to the amount specified, it can
  13.   also be called by:
  14.  
  15.       setstack file
  16.  
  17.   which prints the current amount of stack.
  18.  
  19. ************************************************************/
  20.  
  21. #include <intuition/intuition.h>
  22. #include <workbench/workbench.h>
  23. #include <stdio.h>
  24. #include <functions.h>
  25.  
  26. #define NO_ICONS       4
  27.  
  28. extern ULONG IconBase;
  29.  
  30. /************************************************************
  31.   The following routine just opens the libraries
  32. ************************************************************/
  33.  
  34. short OpenLibs()
  35. {
  36.   short flags; /* any libraries that do not open get recorded here */
  37.  
  38.   flags = 0;
  39.   IconBase = (ULONG) OpenLibrary("icon.library", 0L);
  40.   if (!IconBase) flags |= NO_ICONS;
  41.   return(flags);
  42. }
  43.  
  44. void CloseLibs(flags)
  45. short flags;
  46. {
  47.   if (!(flags & NO_ICONS))     CloseLibrary(IconBase);
  48. }
  49.  
  50. void main(argc, argv)
  51. short argc;
  52. char *argv[];
  53. {
  54.   short lib_flags;
  55.   long stack;
  56.   struct DiskObject *dobj;
  57.  
  58.   if (argc == 3)
  59.   {
  60.     lib_flags  = OpenLibs();
  61.     if (!lib_flags)
  62.     {
  63.       if (dobj = GetDiskObject(argv[1]))
  64.       {
  65.         sscanf(argv[2], "%ld", &stack);
  66.         stack &= ~0x03L;                /* force to be factor of 4 */
  67.         if (stack < 400) stack = 400;
  68.         dobj->do_StackSize = stack;
  69.         PutDiskObject(argv[1], dobj);
  70.         FreeDiskObject(dobj);
  71.       }
  72.     }
  73.     CloseLibs(lib_flags);
  74.   }
  75.   else if (argc == 2)
  76.   {
  77.     lib_flags  = OpenLibs();
  78.     if (!lib_flags)
  79.     {
  80.       if (dobj = GetDiskObject(argv[1]))
  81.       {
  82.         printf("Stack: %ld\n", dobj->do_StackSize);
  83.         FreeDiskObject(dobj);
  84.       }
  85.     }
  86.     CloseLibs(lib_flags);
  87.   }
  88.   else
  89.   {
  90.     printf("Syntax is: setstack icon [amount]\n");
  91.     printf("This is version 1.00\n");
  92.     printf("Written and Copyright (C) 1987 by: Stephen Vermeulen\n");
  93.     printf("                                   3635 Utah Dr. N.W.,\n");
  94.     printf("                                   Calgary, Alberta,\n");
  95.     printf("                                   CANADA, T2N 4A6\n");
  96.     printf("\n                                   (403) 282-7990\n");
  97.     printf("\nSupport more Vware, send a donation or a bug report...\n");
  98.     printf("This program may be freely distributed so long as no\n");
  99.     printf("charge is made for such distribution.\n");
  100.   }
  101. }
  102.